<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>获取盈数</title>
    <script>
      //盈数是一种特殊的自然数，除去它本身以外的一切正约数的和大于它本身
      function isAbundantNum(num) {
        var sum = 0;
        var i = 0; //变量初始化
        while (i <= num) {
          //将寻找到的约数相加
          if (num % i === 0) {
            sum += i;
          }
          i++;
        }
        if (sum - num > num) {
          alert(num + "是盈数");
        } else {
          alert(num + "不是盈数");
        }
      }
      isAbundantNum(parseInt(prompt("请输入一个正整数", "30")));
    </script>
  </head>
  <body></body>
</html>
